package team.xiaobaiya.gptchatrobot.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import team.xiaobaiya.gptchatrobot.entity.database.UserKey;

/**
 * @ClassName UserKeyMapper
 * @Author Feng Yingnan
 * @Email fengyn1211@163.com
 * @Date 2023/4/24 15:29
 */
@Mapper
public interface UserKeyMapper {
    /**
     * 根据user key查询
     * @param userKey user key
     * @return 实体
     */
    UserKey selectByKey(@Param("userKey") String userKey);

    /**
     * 根据user key减少1积分
     * @param userKey user key
     * @return 影响行数
     */
    int updateUsageDecrement(@Param("userKey") String userKey);


    /**
     * 根据user key更新正在加载状态
     * @param userKey user key
     * @param loading 新的状态
     * @return 影响行数
     */
    int updateUserKeyLoading(@Param("userKey") String userKey, @Param("loading")boolean loading);
}
